<?php
function rpc( $json_request ) {
    global $PARAPARA;

    $req_param = $json_request->param;

    if(!$req_param) {
        return new RPC_Error($json_request->operation, "PARAM", "No params");
    }

    $bit_name = $req_param->bit;
    if(!$req_param) {
        return new RPC_Error($json_request->operation, "PARAM", "Missing bit value");
    }

    $account = $PARAPARA->fetch_account();

    ob_start();
    if($bit_name == 'userdata') {
        require "bits/userdata.php";
    }
    elseif($bit_name == 'forum_msg_form') {
        require "bits/forum_msg_form.php";
    }
    elseif($bit_name == 'linkroll_link_form' ) {
        require "bits/linkroll_link_form.php";
    }
    $contents = ob_get_clean();

    if(!$contents) {
        return new RPC_Error($json_request->operation, "PARAM", "Unknown bit:" . $bit_name );
    }

    return new RPC_Response( $json_request->operation, array( 'html' => $contents ) );
  }

return rpc( $json_request );
?>